package com.ebs.md.api;

import com.ebs.md.api.hit.HitSide;

/**
 * Perforce Revision:
 *  $File: //depot/MarketData/commons-md-api/MAIN/src/main/java/com/ebs/md/api/OrderSide.java $
 *  $Revision: #2 $  $Change: 114786 $  $DateTime: 2012/09/10 08:47:19 $  $Author: Arik.Sher $
 */

public enum OrderSide
{
	 BID   (0)
	,OFFER (1)
	;
	 
	private int legacyCode;

	private OrderSide(int legacyCode) {
		this.legacyCode = legacyCode;
	}

	public int getLegacyCode() {
		return legacyCode;
	}
	
	public BookSide getMatchBookSide() {
		if ( this.equals(   BID) ) {
			return BookSide.BID;
		}
		if ( this.equals(   OFFER) ) {
			return BookSide.OFFER;
		}
		return null;
	}

	public HitSide getMatchHitSide() {
		if ( this.equals(  BID) ) {
			return HitSide.SELL;
		}
		if ( this.equals(  OFFER) ) {
			return HitSide.BUY;
		}
		return null;
	}

	public OrderSide getOtherSide() {
		if ( this.equals(BID) ) {
			return OFFER;
		}
		if ( this.equals(OFFER) ) {
			return BID;
		}
		return null;
	}

	public static OrderSide byLegcayCode(int legacyCode) {
		if ( BID.legacyCode == legacyCode ) {
			return BID;
		}
		if ( OFFER.legacyCode == legacyCode ) {
			return OFFER;
		}
		return null;
	}
	
}
